<script>
  /*
  * Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
  * This file is part of RockStor.
  *
  * RockStor is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published
  * by the Free Software Foundation; either version 2 of the License,
  * or (at your option) any later version.
  *
  * RockStor is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  *
  */
</script>
<div class="row-fluid">
  <div class="span8">
    <label class="control-label"></label>
        <div class="messages">
        {{#if isEmailNull}}
        <div class="controls">
	  <div class="alert alert-warning">
	    <p>Rockstor can push notifications to you via e-mail. We recommend
	      creating a separate dedicated e-mail account for this purpose.
	      Rockstor will login to this e-mail account and use it to send
	      notifications to another specified e-mail address, such as your
	      personal gmail account.</p>
	  </div>
      	<button type="Submit" id="Add-email-address" class="btn btn-primary" title="Add an e-mail account to be used for sending notifications.">Add an E-mail account</button>
        {{else}}
	<div class="alert alert-warning">
	  <p>Rockstor uses the credentials below to send e-mail notifications. Any
	    system information sent to the root user results in a
	    notification. Rockstor assumes/uses the <b>Sender</b> account and from
	    that account sends e-mails to the <b>Receiver</b>
	    email address. The <b>Sender</b> e-mail account password is stored in
	    <code>/etc/postfix/sasl_passwd</code> which has restricted
	    permissions. However, we strongly recommend against using a personal
	    or important e-mail account for the <b>Sender</b>. On the other
	    hand the <b>Receiver</b> e-mail address can be anything you have
	    access to and is simply the recipient of the notifications.
	  </p>

	  <p>To test if notifications are setup properly, click
	     on <i class="glyphicon glyphicon-send"></i> icon below to send a
	     test message.
	  </p>
	</div>
        <table id="email-table" class="table table-condensed table-bordered table-hover table-striped share-table " >
          <thead>
            <tr>
              <th scope="col" abbr="Sender">Sender</th>
	      <th scope="col" abbr="Receiver">Reciever</th>
	      <th scope="col" abbr="smtp-server">SMTP Server</th>
	      <th scope="col" abbr="port">Port</th>
              <th scope="col" abbr="Actions">Actions</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>{{email.sender}}</td>
              <td>{{email.receiver}}</td>
              <td>{{email.smtp_server}}</td>
	      <td>{{email.port}}</td>
              <td>
                <a href="#" class="email-delete" id="email-delete" rel="tooltip" title="Delete email"><i class="glyphicon glyphicon-trash"></i></a>
		<a href="#" class="send-test-message" id="send-test-message" rel="tooltip" title="Send a test e-mail"><i class="glyphicon glyphicon-send"></i></a>
              </td>
            </tr>
          </tbody>
        </table>
        {{/if}}
        </div>

        </div>
  </div>
</div>

<div id="test-message-confirm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
	<h3 id="myModalLabel">Test e-mail sent successfully.</h3>
      </div>
      <div class="modal-body">
	<p>Test e-mail has been successfully queued to postfix. Your mail from <code>{{email.sender}}</code> to <code>{{email.receiver}}</code> could take up to several minutes to arrive. If you do not receive it, check <code>/var/log/maillog</code> for clues. You may want to verify the input, delete and add the E-mail account again.</p>
      </div>
    </div>
  </div>
</div>
